/***********************************************************************
 * Module:  Lecturer.java
 * Author:  DAC
 * Purpose: Defines the Class Lecturer
 ***********************************************************************/
package com.group1.model;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

/** @pdOid f9842973-0b2f-4852-bf07-676e527f12ab */
public class Lecturer {
   /** @pdOid 2a01f180-6b26-497b-82bf-eec1bcb5bc7d */
   public java.lang.String lecturerId;
   /** @pdOid e38802c1-87ad-4c16-82b3-27470325d893 */
   public java.lang.String lecturerName;
   
   /** @pdRoleInfo migr=no name=Topic assc=creatorOfTopic coll=java.util.Collection impl=java.util.HashSet mult=0..* */
   public java.util.Collection<Topic> topic;
   /** @pdRoleInfo migr=no name=Question assc=creatorOfQuestions coll=java.util.Collection impl=java.util.HashSet mult=0..* */
   public java.util.Collection<Question> question;
   /** @pdRoleInfo migr=no name=Test assc=creatorOfTests coll=java.util.Collection impl=java.util.HashSet mult=0..* */
   public java.util.Collection<Test> test;
   /** @pdRoleInfo migr=no name=Test assc=validatorOfTests coll=java.util.Collection impl=java.util.HashSet mult=0..* */
   public java.util.Collection<Test> testVal;
   
   /** @pdOid 0da67d14-73dc-40bb-b61c-2a8cb14a264b */
   public java.lang.String getLecturerId() {
      return lecturerId;
   }
   
   /** @param newLecturerId
    * @pdOid dce3d2a1-fc56-48b3-a534-63412e2e0844 */
   public void setLecturerId(java.lang.String newLecturerId) {
      lecturerId = newLecturerId;
   }
   
   /** @pdOid e554fc7b-1211-4e94-83e6-8f7b5449858a */
   public java.lang.String getLecturerName() {
      return lecturerName;
   }
   
   /** @param lecturerID 
    * @param session
    * @pdOid 9f2a3105-c5ea-4c22-aa8e-ca14670da83e */
   public static Lecturer getLecturerById(String lecturerID, Session session) {
      // TODO: implement
      return (Lecturer)session.load(Lecturer.class, lecturerID);
   }
   
   
   public static List<Lecturer> getAllLecturer(Session session)
   {
	   Query query = session.createQuery("from Lecturer");
	   List<Lecturer> list = query.list();
	   return list;
   }
   
   
   /** @param newLecturerName
    * @pdOid 95f2503e-5aee-4000-a325-4aa84d7a28a6 */
   public void setLecturerName(java.lang.String newLecturerName) {
      lecturerName = newLecturerName;
   }
   
   
   /** @pdGenerated default getter */
   public java.util.Collection<Topic> getTopic() {
      if (topic == null)
         topic = new java.util.HashSet<Topic>();
      return topic;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorTopic() {
      if (topic == null)
         topic = new java.util.HashSet<Topic>();
      return topic.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newTopic */
   public void setTopic(java.util.Collection<Topic> newTopic) {
      removeAllTopic();
      for (java.util.Iterator iter = newTopic.iterator(); iter.hasNext();)
         addTopic((Topic)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newTopic */
   public void addTopic(Topic newTopic) {
      if (newTopic == null)
         return;
      if (this.topic == null)
         this.topic = new java.util.HashSet<Topic>();
      if (!this.topic.contains(newTopic))
      {
         this.topic.add(newTopic);
         newTopic.setLecturer(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldTopic */
   public void removeTopic(Topic oldTopic) {
      if (oldTopic == null)
         return;
      if (this.topic != null)
         if (this.topic.contains(oldTopic))
         {
            this.topic.remove(oldTopic);
            oldTopic.setLecturer((Lecturer)null);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllTopic() {
      if (topic != null)
      {
         Topic oldTopic;
         for (java.util.Iterator iter = getIteratorTopic(); iter.hasNext();)
         {
            oldTopic = (Topic)iter.next();
            iter.remove();
            oldTopic.setLecturer((Lecturer)null);
         }
      }
   }
   /** @pdGenerated default getter */
   public java.util.Collection<Question> getQuestion() {
      if (question == null)
         question = new java.util.HashSet<Question>();
      return question;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorQuestion() {
      if (question == null)
         question = new java.util.HashSet<Question>();
      return question.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newQuestion */
   public void setQuestion(java.util.Collection<Question> newQuestion) {
      removeAllQuestion();
      for (java.util.Iterator iter = newQuestion.iterator(); iter.hasNext();)
         addQuestion((Question)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newQuestion */
   public void addQuestion(Question newQuestion) {
      if (newQuestion == null)
         return;
      if (this.question == null)
         this.question = new java.util.HashSet<Question>();
      if (!this.question.contains(newQuestion))
      {
         this.question.add(newQuestion);
         newQuestion.setLecturer(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldQuestion */
   public void removeQuestion(Question oldQuestion) {
      if (oldQuestion == null)
         return;
      if (this.question != null)
         if (this.question.contains(oldQuestion))
         {
            this.question.remove(oldQuestion);
            oldQuestion.setLecturer((Lecturer)null);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllQuestion() {
      if (question != null)
      {
         Question oldQuestion;
         for (java.util.Iterator iter = getIteratorQuestion(); iter.hasNext();)
         {
            oldQuestion = (Question)iter.next();
            iter.remove();
            oldQuestion.setLecturer((Lecturer)null);
         }
      }
   }
   /** @pdGenerated default getter */
   public java.util.Collection<Test> getTest() {
      if (test == null)
         test = new java.util.HashSet<Test>();
      return test;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorTest() {
      if (test == null)
         test = new java.util.HashSet<Test>();
      return test.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newTest */
   public void setTest(java.util.Collection<Test> newTest) {
      removeAllTest();
      for (java.util.Iterator iter = newTest.iterator(); iter.hasNext();)
         addTest((Test)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newTest */
   public void addTest(Test newTest) {
      if (newTest == null)
         return;
      if (this.test == null)
         this.test = new java.util.HashSet<Test>();
      if (!this.test.contains(newTest))
      {
         this.test.add(newTest);
         newTest.setTEST_CREATOR(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldTest */
   public void removeTest(Test oldTest) {
      if (oldTest == null)
         return;
      if (this.test != null)
         if (this.test.contains(oldTest))
         {
            this.test.remove(oldTest);
            oldTest.setTEST_CREATOR((Lecturer)null);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllTest() {
      if (test != null)
      {
         Test oldTest;
         for (java.util.Iterator iter = getIteratorTest(); iter.hasNext();)
         {
            oldTest = (Test)iter.next();
            iter.remove();
            oldTest.setTEST_CREATOR((Lecturer)null);
         }
      }
   }
   /** @pdGenerated default getter */
   public java.util.Collection<Test> getTestVal() {
      if (testVal == null)
         testVal = new java.util.HashSet<Test>();
      return testVal;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorTestVal() {
      if (testVal == null)
         testVal = new java.util.HashSet<Test>();
      return testVal.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newTestVal */
   public void setTestVal(java.util.Collection<Test> newTestVal) {
      removeAllTestVal();
      for (java.util.Iterator iter = newTestVal.iterator(); iter.hasNext();)
         addTestVal((Test)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newTest */
   public void addTestVal(Test newTest) {
      if (newTest == null)
         return;
      if (this.testVal == null)
         this.testVal = new java.util.HashSet<Test>();
      if (!this.testVal.contains(newTest))
      {
         this.testVal.add(newTest);
         newTest.setTEST_VALIDATOR(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldTest */
   public void removeTestVal(Test oldTest) {
      if (oldTest == null)
         return;
      if (this.testVal != null)
         if (this.testVal.contains(oldTest))
         {
            this.testVal.remove(oldTest);
            oldTest.setTEST_VALIDATOR((Lecturer)null);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllTestVal() {
      if (testVal != null)
      {
         Test oldTest;
         for (java.util.Iterator iter = getIteratorTestVal(); iter.hasNext();)
         {
            oldTest = (Test)iter.next();
            iter.remove();
            oldTest.setTEST_VALIDATOR((Lecturer)null);
         }
      }
   }

   public Lecturer()
   {
	   
   }
   
	public Lecturer(String lecturerId, String lecturerName) {
		super();
		this.lecturerId = lecturerId;
		this.lecturerName = lecturerName;
	}
   
   

}